package com.cxsw.rms.controller.webpages;

import com.cxsw.rms.utils.Constants;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * 登录页面跳转控制器
 *
 * @author Han Fuhao
 * @date 2023/05/14
 */
@Controller
public class LoginPageController {
    /**
     * 登录页面跳转
     *
     * @return {@link String}
     */
    @RequestMapping("toLogin")
    public String toLogin(HttpSession httpSession) {
        if (httpSession.getAttribute(Constants.SESSION_USER) != null) {
            return "redirect:/toMain";
        }
        return "login";
    }

    /**
     * 主界面跳转
     *
     * @return {@link String}
     */
    @RequestMapping("toMain")
    public String toMain() {
        return "main";
    }

    /**
     * 注册页面跳转
     *
     * @return {@link String}
     */
    @RequestMapping("toRegister")
    public String toRegister() {
        return "register";
    }

    /**
     * 学生注册页面跳转
     *
     * @return {@link String}
     */
    @RequestMapping("toStudentRegister")
    public String toStudentRegister() {
        return "student-register";
    }
}
